package MapDemo.TreeMapdemo;

import java.util.Comparator;
import java.util.TreeMap;

public class test {
    public static void main(String[] args){
        // 创建集合对象
        TreeMap<Integer,String> tm = new TreeMap<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer s1,Integer s2){
                return s1 - s2;
            }
        });

        // 添加元素
        tm.put(18,"阅历月");
        tm.put(21,"sjs");
        tm.put(20,"s21");
        System.out.println(tm);
    }
}
